//
// Created by xm on 2024/8/12.
//

#include "Test083.h"
using namespace std;
#include <list>
#include "iostream"





static void demo01()
{
    cout << "====== demo01 ======" << endl;
    list<int>::iterator it;

    list<int> myList;
    for (int i =0; i<10; i++){
        myList.push_back(i);
    }

    for (it = myList.begin(); it != myList.end();++it)
    {
        cout << *it << " ";
    }
    cout  << endl;
}

void printBinary(char n) {
    for (int i = sizeof(n) * 8 - 1; i >= 0; i--) {
        printf("%d", (n >> i) & 1);
    }
    printf("\n");
}

static void demo02()
{
    // 1的源码：0000 0001
    // 反码：1的源码+1 1111 1110
    // 补码：反码 + 1  = 1111 1111
    char a = -1; // 11111111

    printBinary(a);

    a = -2;
    printBinary(a);

    a = -127;
    printBinary(a);

    a = -128;
    printBinary(a);

}



void  test083(){
//    demo01();
    demo02();
}